<?php

/*
 * 作者:liuleyi
 * 功能描述:产品属性类型控制器
 * 修改记录
 * 修改时间   修改人     修改描述
 */

namespace Admin\Controller;

use Think\Controller;

class ProductPropertyTypeController extends Controller {

    public function add() {
        if (!empty($_POST)) {

            $func = new \Admin\Func\Func902020106(I(VAR_PRODUCTCODE), I(VAR_PRODUCTPROPERTYTYPEID), I(VAR_PRODUCTPROPERTYTYPENAME), I(VAR_PRODUCTPROPERTYTYPESORT));

            if ($func->execute() === false) {
                $this->error("新增失败:" . $func->getErrMsg());
            } else {
                // $this->display();
                $this->success('新增成功！');
            }
            //  $this->display();
        } else {
            $this->display();
        }
    }

    public function del($ProductCode, $ProductPropertyTypeID) {
        $func = new \Admin\Func\Func902020110($ProductCode, $ProductPropertyTypeID);
        if ($func->execute() === false) {
            $this->error('删除失败' . $func->getErrMsg());
        } else {
            $this->redirect('ProductPropertyType/lst');
        }
    }

    public function edit($ProductCode, $ProductPropertyTypeID) {
        if (!empty($_POST)) {
            $func = new \Admin\Func\Func902020107(I(VAR_PRODUCTCODE), I(VAR_PRODUCTPROPERTYTYPEID), I(VAR_PRODUCTPROPERTYTYPENAME), I(VAR_PRODUCTPROPERTYTYPESORT));
            if ($func->execute() === false) {
                $this->error("编辑失败:" . $func->getErrMsg());
            } else {
                $this->success('编辑成功！');
            }
        } else {

            $func = new \Admin\Func\Func902020109($ProductCode, $ProductPropertyTypeID);
            if ($func->execute() === false) {
                $this->error('查询失败:' . $func->getErrMsg());
            } else {
                $this->assign(POST, $func->getRst()[0]);
                $this->display();
            }
        }
    }

    public function lst() {
        $func = new \Admin\Func\Func902020108(I(VAR_PRODUCTCODE));
        if ($func->execute() === false) {
            $this->error('查询失败:' . $func->getErrMsg());
        } else {
            $this->ajaxReturn($func->getRst());
        }
    }

}
